<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/25
 * Time: 17:35
 */
namespace app\index\controller;

use think\Controller;
use think\Request;

class TalkLogin extends Controller{
    /**
     * talk login and have three roles
     */
    public function login(Request $request){
        $username = $request->post('userLoginName');
        $password = $request->post('userPassword');
        if($request->post('role') == '请选择角色'){
            return json(array('state' => 0, 'msg' => '请选择角色'));
        }
        if($username == '' || $password == ''){
            return json(array('state' => 0, 'msg' => '帐号密码不能为空'));
        }
        $data                 = array();
        $data['username']     = $username;
        $data['userpassword'] = $password;
        switch($request->post('role')){
            case '主讲(老师)':
                $data['usertype'] = 0;
                break;
            case '助教':
                $data['usertype'] = 1;
                break;
            case '学员':
                $data['usertype'] = 2;
                break;
            case '直播用户':
                $data['usertype'] = 3;
                break;
            case '巡检员':
                $data['usertype'] = 4;
                break;
            default:
                break;
        }
        $data['ts']     = time();
        $data['pid']    = 0;
        $data['serial'] = 0; //房间编号
        $data['pid']    = 0;

        p($request->post());
    }
}